package com.afkt.accessibility.slice;

import com.afkt.accessibility.ResourceTable;
import com.afkt.accessibility.utils.SystemUtils;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class AccessAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        // 加载XML布局
        super.setUIContent(ResourceTable.Layout_ability_accessibility);

        Button button = (Button) findComponentById(ResourceTable.Id_accessibility_title);
        if (button != null) {
            button.setClickedListener(new Component.ClickedListener() {
                @Override
                public void onClick(Component component) {
                    // 鸿蒙API无法获取无障碍权限，暂时只能实现跳转设置页面
                    Intent intent = SystemUtils.openSystemSetting();
                    startAbility(intent);
                }
            });
        }

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
